package voxietest1;

import processing.core.PVector;
import voxbox.wrapper.VoxiFrame;

public class Particle extends VoxiObject {
	PVector pos;
	PVector vel;
	float lifetime;
	
	Particle(float lifetime) {
		pos = new PVector(0,0,0);
		vel = new PVector(0,0,0);
		this.lifetime = lifetime;
	}
	 
	Particle(PVector position, PVector velocity, float lifetime) {
		pos = position.get();
		vel = velocity.get();
		this.lifetime = lifetime;
	}
	
	public void mySetup() {}
	
	public void myUpdate() {
		float timestep = (float)scene.deltaTime;
		pos.add(PVector.mult(vel, timestep));
		lifetime -= timestep;
	}
	
	boolean isAlive() {
		return lifetime > 0;
	}
	
	public void myDraw() {
		if (lifetime > 0) {
			//voxi.voxi_drawsph(scene.frame, pos.x, pos.y, pos.z, .01f, .01f, 7);
			voxi.voxi_drawvox(scene.frame,  pos.x, pos.y, pos.z, 7);
		}
	}	
}
